package webmarket.model;

import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;


/**
 * The persistent class for the merchandise database table.
 * 
 */
@Entity
@Table(name="merchandise")
@NamedQuery(name="Merchandise.findAll", query="SELECT m FROM Merchandise m")
public class Merchandise implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private int id;

	private String categoryname;

	private Timestamp created;

	private String description;

	private Timestamp lastchange;

	private String name;

	private int price;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="userid")
	private User user;

	//bi-directional many-to-one association to Picture
	@OneToMany(mappedBy="merchandise")
	private List<Picture> pictures;

	public Merchandise() {
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getCategoryname() {
		return this.categoryname;
	}

	public void setCategoryname(String categoryname) {
		this.categoryname = categoryname;
	}

	public Timestamp getCreated() {
		return this.created;
	}

	public void setCreated(Timestamp created) {
		this.created = created;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Timestamp getLastchange() {
		return this.lastchange;
	}

	public void setLastchange(Timestamp lastchange) {
		this.lastchange = lastchange;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getPrice() {
		return this.price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<Picture> getPictures() {
		return this.pictures;
	}

	public void setPictures(List<Picture> pictures) {
		this.pictures = pictures;
	}

	public Picture addPicture(Picture picture) {
		getPictures().add(picture);
		picture.setMerchandise(this);

		return picture;
	}

	public Picture removePicture(Picture picture) {
		getPictures().remove(picture);
		picture.setMerchandise(null);

		return picture;
	}

}